package main

import (
	"bytes"
	"fmt"
	"math"
	"math/cmplx"
	"strconv"
	"unicode/utf8"
)

func main() {
	var x complex128 = 1 + 2i
	var y complex128 = complex(3, 4)
	fmt.Println(x * y)
	fmt.Println(real(x * y))
	fmt.Println(cmplx.Abs(x))
	fmt.Println(cmplx.Sqrt(5))
	str := "hello, 世界"
	for i, r := range str {
		fmt.Printf("%d %q %d\n", i, r, r)
	}
	fmt.Println(len(str))
	fmt.Println(utf8.RuneCountInString(str))
	s := "abc"
	b := []byte(s)
	b[1] = 'c'
	s2 := string(b)

	fmt.Println(s, s2, b)
	// const (
	// 	_   = 1000 * iota
	// 	KiB = 1000
	// 	MiB = 1000 * KiB
	// 	GiB = 1000 * MiB
	// 	TiB = 1000 * GiB
	// 	PiB = 1000 * TiB
	// 	EiB = 1000 * PiB
	// 	YiB = 1000 * EiB
	// )
	// fmt.Println(KiB, MiB, GiB, TiB, PiB, EiB)
	// fmt.Printf("%v", YiB/TiB)
	var f float64 = 212
	fmt.Printf("%T\n", (f-32)*5/9)

	a := 123
	n := fmt.Sprintf("%d", a)
	m := strconv.Itoa(a)
	fmt.Println(n, m)
	o, _ := strconv.Atoi(m)
	fmt.Printf("%T\t%T\t%T\n", n, m, o)
	fmt.Println(strconv.FormatUint(uint64(a), 2))

	s = "hello,中国"
	for i := 0; i < len(s); i++ {
		r, size := utf8.DecodeRuneInString(s[i:])
		fmt.Printf("%d\t%c\t%d\n", i, r, size)
		i += size - 1
	}
	i := 0
	for range s {
		i++
	}
	fmt.Println(n)
	s1 := `
		中国
	`
	fmt.Println(len(s))
	fmt.Println(s1)
	fmt.Printf(" %x\n", s)
	fmt.Println(string(65))   //A
	fmt.Println(string("65")) //65
	fmt.Println(bytes.Join([][]byte{{'a', 'b', 'c'}, {'c', 'd'}}, []byte(" ")))
	fmt.Println(math.Pow(10, 3))
	const (
		_ = uint64(math.Pow(10, 3))
		KB
		MB
		GB
		TB
		PB
		EB
		ZB
		YB
	)
}
